import { fetchJson } from '@/lib/utils/server';
import { ResultDto } from '@/types/response/common';
import { ChannelDetail } from '@/types/channel';
import { notFound } from 'next/navigation';
import WatchView from './WatchView';

type Props = {
	params: Promise<{ channelSID: string }>;
};

export default async function WatchPage({ params }: Props) {
	const { channelSID } = await params;
	const res: ResultDto<ChannelDetail> = await fetchJson(`/api/channel/${channelSID}`, { method: 'GET' });

	if (!res.data) {
		notFound();
	}

	return <WatchView channel={res.data} />;
}